﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 报工类型
    /// </summary>
    public enum SubmittedType
    {
        /// <summary>
        /// 线体组件
        /// </summary>
        Component=0,
        /// <summary>
        /// 成品
        /// </summary>
        Product=1
    }

    /// <summary>
    /// 报工角色
    /// </summary>
    public enum SubmittedRole
    {
        /// <summary>
        /// 电气自动化程序
        /// </summary>
        Automatic = 0,
        /// <summary>
        /// 现场操作工
        /// </summary>
        Operator=1,
        /// <summary>
        /// 工段长（管理员人）
        /// </summary>
        Manager=2,
    }

    /// <summary>
    /// 报工状态
    /// </summary>
    public enum SubmittedStatus
    {
        /// <summary>
        /// 取消报工(误报时取消)
        /// </summary>
        Cancel=0,
        /// <summary>
        /// 正常
        /// </summary>
        Normal=1,
        /// <summary>
        /// 追加(漏报时，补报)
        /// </summary>
        Append=2
    }

    /// <summary>
    /// 工位执行情况(生产报工)
    /// </summary>
    public partial class StationExecuted : BusEntity
    {
        public StationExecuted()
        {
            CreateTime = DateTime.Now;
        }

        /// <summary>
        /// 工位ID
        /// </summary>
        public string StationCode { set; get; }

        /// <summary>
        /// 计划编号
        /// </summary>
        public string PlanId { set; get; }

        /// <summary>
        /// 电气工件型号
        /// </summary>
        public string EleCode { set; get; }

        /// <summary>
        /// 报工时间
        /// </summary>
        public DateTime SubTime { set; get; }

        /// <summary>
        /// 报工数量
        /// </summary>
        public int Quantity { set; get; }

        /// <summary>
        /// 报工类型
        /// </summary>
        public SubmittedType SubType { set; get; }

        /// <summary>
        /// 报工角色
        /// </summary>
        public SubmittedRole SubRole { set; get; }

        /// <summary>
        /// 报工状态
        /// </summary>
        public SubmittedStatus SubStatus { set; get; }
    }

    public partial class StationExecuted : BusEntity
    {
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class StationExecutedTypeConfig : BusEntityTypeConfig<StationExecuted>, IEntityTypeConfiguration<StationExecuted>
    {
        public override void Configure(EntityTypeBuilder<StationExecuted> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.StationCode).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.SubType).IsRequired();
            builder.Property(p => p.SubRole).IsRequired();
            builder.Property(p => p.SubStatus).IsRequired();
            builder.Property(p => p.SubTime).IsRequired();
            builder.Property(p => p.Quantity).IsRequired();
            #endregion

            #region 备注
            builder.HasComment("工位执行情况(生产报工)");
            builder.Property(p => p.StationCode).HasComment("工位ID");
            builder.Property(p => p.SubType).HasComment("报工类型");
            builder.Property(p => p.SubRole).HasComment("报工角色");
            builder.Property(p => p.SubStatus).HasComment("报工状态");
            builder.Property(p => p.SubTime).HasComment("报工时间");
            builder.Property(p => p.Quantity).HasComment("报工数量");
            #endregion

            #region 种子数据
            #endregion
        }
    }
}
